package com.nononsenseapps.feeder.net.fever.model

import com.nononsenseapps.feeder.db.entity.ATTENTION_NORMAL
import com.nononsenseapps.feeder.db.entity.FeedItem
import com.squareup.moshi.JsonClass
import java.util.*

@JsonClass(generateAdapter = true)
data class FeverFeedItem(val id:Int,
                         val feed_id:Int,
                         val title:String,
                         val author:String,
                         val html:String,
                         val url:String,
                         val is_saved:Boolean,
                         val is_read:Boolean,
                         val created_on_time:Date
){
    constructor(item: FeedItem) : this(
        id=item.id.toInt(),
        feed_id=item.feedId!!.toInt(),
        title=item.title,
        author=item.author?:"",
        html=item.description,
        url=item.link?:"",
        is_saved=item.attentionLevel> ATTENTION_NORMAL,
        is_read=!item.unread,
        created_on_time=item.createDate.toDate()
    )
}
